#!/bin/bash

# 执行代码检查
echo "提交规范检查.............."
commit_msg=`cat $1`
echo $commit_msg
email=`git config user.email`
echo $email

msg_re1="^(ADD|MODIFY|FIX|HOTFIX|TEST|REFACTOR|DOCS|STYLE|CHROE)(\(.+\))?: .{1,100}"
pattern='^(ADD|MODIFY|FIX|HOTFIX|TEST|REFACTOR|DOCS|STYLE|CHROE)\(.*\):.*$'
msg_re="^(ADD|MODIFY|FIX|HOTFIX|TEST|REFACTOR|DOCS|STYLE|CHROE).*:.*$"
msg_re="^(ADD|MODIFY|FIX|HOTFIX|TEST|REFACTOR|REFINE|DOCS|STYLE):.*$"
if [[ $commit_msg =~ $msg_re ]] 
then
	echo -e "\033[32m commit success! \033[0m"
	exit 0
else
  echo -e "\033[31m Error: the commit message is irregular \033[m"
	exit 1
fi
